package com.example.administrator.scan2web;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.google.zxing.Result;

import me.dm7.barcodescanner.zxing.ZXingScannerView;

/**
 * Created by Administrator on 2017/5/26.
 */

public class MainActivity2L extends AppCompatActivity implements ZXingScannerView.ResultHandler {
    private ZXingScannerView mZXingScannerView;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mZXingScannerView = new ZXingScannerView(this); // 将ZXingScannerView作为布局
        setContentView(mZXingScannerView);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mZXingScannerView.setResultHandler(this); // 设置处理结果回调
        mZXingScannerView.startCamera(); // 打开摄像头
    }

    @Override
    protected void onPause() {
        super.onPause();
        mZXingScannerView.stopCamera(); // 活动失去焦点的时候关闭摄像头
    }


    @Override
    public void handleResult(Result result) {
        String ll = "http://demo.companyhf.com:8001/s.aspx?key="+result.getText();
        Intent intent = new Intent(this,WebActivity.class);
        intent.putExtra("url",ll);
        startActivity(intent);
    }
}
